/**
  ******************************************************************************
  * @文件名           : fml_alarm.c
  * @作者             : citunhk
  * @功能介绍         : 报警检测
  *	@日期             : 2022.11.14
  ******************************************************************************
  * @注意
  *
  *
  *
  ******************************************************************************
  *更改记录
  *日期 修改人 修改内容
  *
  *
  *
  ******************************************************************************
  */
#include "fml_alarm.h"
#include "sys_data.h"
#include "dri_DigitalQuantity.h"
#include "dri_AnalogQuantity.h"

/**
* @函数名	FML_Alarm_LowLevel
* @功能	    低液位开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_LowLevel(void)
{
	static uint16_t pUPAlarmTime_LevelRightDown = 0;		//低液位下正常计时
	static uint16_t pUPAlarmTime_LevelLowDown = 0;		//低液位下报警计时
	static uint16_t pUPAlarmTime_LevelRightUp = 0;		//低液位上正常计时
	static uint16_t pUPAlarmTime_LevelLowUp = 0;		//低液位上报警计时
	static uint16_t pAlarmTime_LevelRightHigh = 0;		//高液位正常计时
	static uint16_t pAlarmTime_LevelHigh = 0;		//高液位报警计时

	//低液位下
	if(DRI_EQU_GetFunState(LOW_LEVEL_FAULT) == ON)  //低液位下低液位
	{
		pUPAlarmTime_LevelRightDown = 0;
		if(++pUPAlarmTime_LevelLowDown > 40)  //延时4S
		{
		  gAlaFlag_LowLevel = 1;
		  pUPAlarmTime_LevelLowDown = 40;
		}
	}
	else  //低液位下正常
	{
		pUPAlarmTime_LevelLowDown = 0;
		if(++pUPAlarmTime_LevelRightDown > 40)  //延时4S
		{
	      gAlaFlag_LowLevel = 0;
		  pUPAlarmTime_LevelRightDown = 40;
		}
	}

	//低液位上
	if(DRI_EQU_GetFunState(LOW_LEVEL_ALARM) == ON)  //低液位
	{
		pUPAlarmTime_LevelRightUp = 0;
		if(++pUPAlarmTime_LevelLowUp > 40)  //延时4S
		{
		  gAlaFlag_LowLevelUP = 1;
		  pUPAlarmTime_LevelLowUp = 40;
		}
	}
	else  //正常液位
	{
		pUPAlarmTime_LevelLowUp = 0;
		if(++pUPAlarmTime_LevelRightUp > 40)  //延时4S
		{
		  gAlaFlag_LowLevelUP = 0;
		  pUPAlarmTime_LevelRightUp = 40;
		}
	}

	//高液位
	if(DRI_EQU_GetFunState(HIGHT_LEVEL) == OFF)  //高液位
	{
		pAlarmTime_LevelRightHigh = 0;
		if(++pAlarmTime_LevelHigh > 40)  //延时4S
		{
			gAlaFlag_HighLevel = 1;
			pAlarmTime_LevelHigh = 40;
		}
	}
	else  //正常液位
	{
		pAlarmTime_LevelHigh = 0;
		if(++pAlarmTime_LevelRightHigh > 40)  //延时4S
		{
			gAlaFlag_HighLevel = 0;
			pAlarmTime_LevelRightHigh = 40;
		}
	}

	//液位状态标志
	if(gAlaFlag_LowLevel == 1)  //低液位故障
	{
		gState_Level = 1;
	}
	else if(gAlaFlag_LowLevelUP == 1)  //低液位报警
	{
		gState_Level = 2;
	}
	else if(gAlaFlag_HighLevel == 1)  //高液位报警
	{
		gState_Level = 4;
	}
	else  //液位正常
	{
		gState_Level = 3;
	}
}

/**
* @函数名	FML_Alarm_FacTemp
* @功能	    工厂保护温度报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FacTemp(void)
{
	static uint16_t pFPAlarmTime_LowTemp = 0;		//工厂低温温度报警延时
	static uint16_t pFPAlarmTime_HighTemp = 0;		//工厂高温温度报警延时

	if(FP.Para.Type_LL_TempFF != 2)  //工厂低温保护温度未关闭
	{
		if(gPV_Temp1 < FP.Para.LL_TempFF)  //工厂低温报警
		{
			  if(++pFPAlarmTime_LowTemp > 20)  //延时2S
			  {
				  gAlaFlag_FacLowTemp = 1;
				  pFPAlarmTime_LowTemp = 20;
			  }
		}
		else  //无工厂低温报警
		{
			  gAlaFlag_FacLowTemp = 0;
			  pFPAlarmTime_LowTemp = 0;
			  if(FP.Para.Type_HL_TempFF != 2)
			  {
				  if(gPV_Temp1 > FP.Para.HL_TempFF)  //工厂高温报警
				  {
					  if(++pFPAlarmTime_HighTemp > 20)  //延时2S
					  {
						  gAlaFlag_FacLowTemp = 0;
						  gAlaFlag_FacHighTemp = 1;
						  pFPAlarmTime_HighTemp = 20;
					  }
				  }
				  else  //工厂无报警
				  {
					  gAlaFlag_FacHighTemp = 0;
					  pFPAlarmTime_LowTemp = 0;
					  pFPAlarmTime_HighTemp = 0;
				  }
			  }
			  else
			  {
				  gAlaFlag_FacHighTemp = 0;
				  pFPAlarmTime_HighTemp = 0;
			  }
		}
	}
	else  //关闭工厂低温报警
	{
		  gAlaFlag_FacLowTemp = 0;
		  pFPAlarmTime_LowTemp = 0;
	}
}

/**
* @函数名	FML_Alarm_FacLowFlow
* @功能	    工厂保护流量限值报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FacLowFlow(void)
{
	static uint16_t pAlarmTime_Flow = 0;		//低流量限值报警延时

	if(FP.Para.ES_Flow != 0)  //低流量检测未关闭
	{
		if(gTime_RunPump > 0)  //水泵启动
		{
		  if(gPV_Flow < FP.Para.LL_FlowFF)  //低流量
		  {
			  if(++pAlarmTime_Flow > 100)  //确认延时
			  {
				  gAlaFlag_FacLowFlow1 = 1;
				  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
				  pAlarmTime_Flow = 100;
			  }
		  }
		  else  //流量正常
		  {
			  pAlarmTime_Flow = 0;

			  if(FP.Para.Type_LL_Flow == 0)
			  {
				  gAlaFlag_FacLowFlow1 = 0;
			  }
		  }
		}
		else
		{
			pAlarmTime_Flow = 0;
		}
	}
	else  //低流量检测关闭
	{
		gAlaFlag_FacLowFlow1 = 0;
		pAlarmTime_Flow = 0;
	}
}

/**
* @函数名	FML_Alarm_Temp
* @功能	    用户保护温度报警温度检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Temp(void)
{
	static uint8_t pUPAlarmFlag_Temp = 0;  //温度检测标志位
	static uint16_t pUPFLTTime_LowTemp = 0;		//用户保护温度低温报警延时
	static uint16_t pUPFLTTime_HighTemp = 0;		//用户保护温度高温报警延时
	static uint16_t pUPAlarmTime_LowTemp = 0;		//用户报警温度低温报警延时
	static uint16_t pUPAlarmTime_HighTemp = 0;		//用户报警温度高温报警延时

	if(UP.Para.AlarmType_Temp == 0)  //运行后
	{
		if(gTime_RunPump > FP.Para.AlarmStartTime_Temp)  //检测延时
		{
			pUPAlarmFlag_Temp = 1;
		}
		else
		{
			pUPAlarmFlag_Temp = 0;
			gAlaFlag_LowTemp = 0;
			gAlaFlag_HighTemp = 0;
			gAlaFlag_LowTemp1 = 0;
			gAlaFlag_HighTemp1 = 0;
		}
	}
	else if(UP.Para.AlarmType_Temp == 1)  //上电后
	{
		if(gAlarmTimeCnt > FP.Para.AlarmStartTime_Temp)  //检测延时
		{
			pUPAlarmFlag_Temp = 1;
		}
		else
		{
			pUPAlarmFlag_Temp = 0;
			gAlaFlag_LowTemp = 0;
			gAlaFlag_HighTemp = 0;
			gAlaFlag_LowTemp1 = 0;
			gAlaFlag_HighTemp1 = 0;
		}
	}
	else  //关闭
	{
		pUPAlarmFlag_Temp = 0;
		gAlaFlag_LowTemp = 0;
		gAlaFlag_HighTemp = 0;
		gAlaFlag_LowTemp1 = 0;
		gAlaFlag_HighTemp1 = 0;
		pUPAlarmTime_LowTemp = 0;
		pUPAlarmTime_HighTemp = 0;
	}

	if(pUPAlarmFlag_Temp == 1)  //可以检测
	{
		//用户保护
		if(UP.Para.AlarmType_TempLL != 2)  //报警下限检测未关闭
		{
			if(gPV_Temp1 < UP.Para.FLT_LL_Temp1)  //低温报警
			{
			  if(++pUPFLTTime_LowTemp > FP.Para.AlarmOutTime_Temp)  //确认时长
			  {
				  gAlaFlag_LowTemp = 1;
				  gAlaFlag_HighTemp = 0;
				  pUPFLTTime_LowTemp = (FP.Para.AlarmOutTime_Temp*10);
			  }
			}
			else  //高温报警
			{
			  gAlaFlag_LowTemp = 0;
			  pUPFLTTime_LowTemp = 0;
			  if(UP.Para.AlarmType_TempHL != 2)  //报警上限检测未关闭
			  {
				  if(gPV_Temp1 > UP.Para.FLT_HL_Temp1)  //高温报警
				  {
					  if(++pUPFLTTime_HighTemp > FP.Para.AlarmOutTime_Temp)  //确认时长
					  {
						  gAlaFlag_LowTemp = 0;
						  gAlaFlag_HighTemp = 1;
						  pUPFLTTime_HighTemp = FP.Para.AlarmOutTime_Temp;
					  }
				  }
				  else  //无用户报警
				  {
					  gAlaFlag_HighTemp = 0;
					  pUPFLTTime_LowTemp = 0;
					  pUPFLTTime_HighTemp = 0;
				  }
			  }
			  else  //关闭高温报警
			  {
				  gAlaFlag_HighTemp = 0;
				  pUPFLTTime_HighTemp = 0;
			  }
			}
		}
		else  //关闭低温报警
		{
			gAlaFlag_LowTemp = 0;
			pUPFLTTime_LowTemp = 0;
		}

		//用户报警
		if(UP.Para.Alarm_HL_Temp1 != UP.Para.Alarm_LL_Temp1)  //未关闭
		{
			if(gPV_Temp1 < UP.Para.Alarm_LL_Temp1)  //低温报警
			{
			  if(++pUPAlarmTime_LowTemp > FP.Para.AlarmOutTime_Temp)  //确认时长
			  {
				  gAlaFlag_LowTemp1 = 1;
				  gAlaFlag_HighTemp1 = 0;
				  pUPAlarmTime_LowTemp = (FP.Para.AlarmOutTime_Temp*10);
			  }
			}
			else  //高温报警
			{
			  gAlaFlag_LowTemp1 = 0;
			  pUPAlarmTime_LowTemp = 0;
			  if(UP.Para.Alarm_HL_Temp1 != UP.Para.Alarm_LL_Temp1)  //未关闭
			  {
				  if(gPV_Temp1 > UP.Para.Alarm_HL_Temp1)  //高温报警
				  {
					  if(++pUPAlarmTime_HighTemp > FP.Para.AlarmOutTime_Temp)  //确认时长
					  {
						  gAlaFlag_LowTemp1 = 0;
						  gAlaFlag_HighTemp1 = 1;
						  pUPAlarmTime_HighTemp = FP.Para.AlarmOutTime_Temp;
					  }
				  }
				  else  //无用户报警
				  {
					  gAlaFlag_HighTemp1 = 0;
					  pUPAlarmTime_LowTemp = 0;
					  pUPAlarmTime_HighTemp = 0;
				  }
			  }
			  else  //关闭高温报警
			  {
				  gAlaFlag_HighTemp1 = 0;
				  pUPAlarmTime_HighTemp = 0;
			  }
			}
		}
		else  //关闭低温报警
		{
			gAlaFlag_LowTemp1 = 0;
			pUPAlarmTime_LowTemp = 0;
		}
  }
}

/**
* @函数名	FML_Alarm_FacCHWLowFlow
* @功能	    冷冻水低流量开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FacCHWLowFlow(void)
{
	static uint16_t pUPAlarmTime_FacCHWFlow = 0;		//低流量开关报警延时

	if(FP.Para.ES_InFlowLL == 2)  //低流量开关检测未关闭
	{
		  if(gTime_RunPump > 200)  //检测延时  20S
		  {
			  if(DRI_EQU_GetFunState(OUTPUT_LOW_FLOW) == ON)  //低流量
			  {
				  if(++pUPAlarmTime_FacCHWFlow > 20)  //确认延时  2S
				  {
					  gAlaFlag_FacLowFlow = 1;
					  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
					  pUPAlarmTime_FacCHWFlow = 20;
				  }
			  }
			  else  //流量正常
			  {
				  gAlaFlag_FacLowFlow = 0;
				  pUPAlarmTime_FacCHWFlow = 0;
			  }
		  }
	}
	else  //低流量开关检测关闭
	{
	  gAlaFlag_FacLowFlow = 0;
	  pUPAlarmTime_FacCHWFlow = 0;
	}
}

/**
* @函数名	FML_Alarm_FacInLowFlow
* @功能	    内循环低流量开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FacInLowFlow(void)
{
	static uint16_t pUPAlarmTime_InCHWFlow = 0;		//低流量开关报警延时

	if(FP.Para.ES_InFlowLL == 1)  //低流量开关检测未关闭
	{
		  if(gTime_RunPump > 200)  //检测延时  20S
		  {
			  if(DRI_EQU_GetFunState(OUTPUT_LOW_FLOW) == ON)  //低流量
			  {
				  if(++pUPAlarmTime_InCHWFlow > 20)  //确认延时  2S
				  {
					  gAlaFlag_FacInLowFlow = 1;
					  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
					  pUPAlarmTime_InCHWFlow = 20;
				  }
			  }
			  else  //流量正常
			  {
//				  gAlaFlag_FacInLowFlow = 0;
				  pUPAlarmTime_InCHWFlow = 0;
			  }
		  }
	}
	else  //低流量开关检测关闭
	{
	  gAlaFlag_FacInLowFlow = 0;
	  pUPAlarmTime_InCHWFlow = 0;
	}
}

/**
* @函数名	FML_Alarm_FacCOWLowFlow
* @功能	    冷却水低流量开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FacCOWLowFlow(void)
{
	static uint16_t pUPAlarmTime_FacCOWFlow = 0;		//低流量开关报警延时

	if(FP.Para.ES_COWFlowLL != 0)  //报警
	{
		  if(gTime_RunPump > 200)  //检测延时  20S
		  {
			  if(DRI_EQU_GetFunState(INPUT_LOW_FLOW) == ON)  //低流量
			  {
				  if(++pUPAlarmTime_FacCOWFlow > 20)  //确认延时  2S
				  {
					  gAlaFlag_COWLowFlow = 1;
//					  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
					  pUPAlarmTime_FacCOWFlow = 20;
				  }
			  }
			  else  //流量正常
			  {
				  gAlaFlag_COWLowFlow = 0;
				  pUPAlarmTime_FacCOWFlow = 0;
			  }
		  }
	}
	else  //低流量开关检测关闭
	{
	  gAlaFlag_COWLowFlow = 0;
	  pUPAlarmTime_FacCOWFlow = 0;
	}
}

/**
* @函数名	FML_Alarm_LowFlow
* @功能	    用户流量限值报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_LowFlow(void)
{
	static uint16_t pUPAlarmTime_Flow = 0;		//低流量限值报警延时

	if(UP.Para.AlarmType_FlowLL != 2)  //低流量检测未关闭
	{
		  if(gTime_RunPump > FP.Para.AlarmStartTime_Flow)  //检测延时
		  {
			  if(gPV_Flow < UP.Para.Alarm_LL_Flow)  //低流量
			  {
				  if(++pUPAlarmTime_Flow > FP.Para.AlarmOutTime_Flow)  //确认延时
				  {
					  gAlaFlag_LowFlow = 1;
					  pUPAlarmTime_Flow = FP.Para.AlarmOutTime_Flow;
				  }
			  }
			  else  //流量正常
			  {
				  gAlaFlag_LowFlow = 0;
				  pUPAlarmTime_Flow = 0;
			  }
		  }
	}
	else  //低流量检测关闭
	{
	  gAlaFlag_LowFlow = 0;
	  pUPAlarmTime_Flow = 0;
	}
}

/**
* @函数名	FML_Alarm_OutPress
* @功能	    用户出液回液压力限值检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_OutInPress(void)
{
	static uint16_t pUPAlarmTime_HL_Press = 0;		//出液压力上限限值报警延时
	static uint16_t pUPAlarmTime_LL_Press = 0;		//出液压力下限限值报警延时

	//出液压力上限限值检测
	if(UP.Para.AlarmType_PressHL != 2)  //出液压力上限检测未关闭
	{
		  if(gTime_RunPump > FP.Para.AlarmStartTime_Flow)  //检测延时
		  {
			  if(gPV_Press_Out > UP.Para.Alarm_HL_Press)  //高压力
			  {
				  if(++pUPAlarmTime_HL_Press > FP.Para.AlarmOutTime_Flow)  //确认延时
				  {
					  gAlaFlag_HL_OutPress = 1;
					  pUPAlarmTime_HL_Press = FP.Para.AlarmOutTime_Flow;
				  }
			  }
			  else  //压力上限正常
			  {
				  if(UP.Para.AlarmType_PressHL == 0)  //报警模式
				  {
					  gAlaFlag_HL_OutPress = 0;
					  pUPAlarmTime_HL_Press = 0;
				  }
			  }
		  }
	}
	else  //出液压力上限检测关闭
	{
		gAlaFlag_HL_OutPress = 0;
		pUPAlarmTime_HL_Press = 0;
	}

	//出液压力下限限值检测
	if(UP.Para.AlarmType_PressLL != 2)  //出液压力下限检测未关闭
	{
		  if(gTime_RunPump > FP.Para.AlarmStartTime_Flow)  //检测延时
		  {
			  if(gPV_Press_Out < UP.Para.Alarm_LL_Press)  //低压力
			  {
				  if(++pUPAlarmTime_LL_Press > FP.Para.AlarmOutTime_Flow)  //确认延时
				  {
					  gAlaFlag_LL_OutPress = 1;
					  pUPAlarmTime_LL_Press = FP.Para.AlarmOutTime_Flow;
				  }
			  }
			  else  //压力下限正常
			  {
				  if(UP.Para.AlarmType_PressLL == 0)  //报警模式
				  {
					  gAlaFlag_LL_OutPress = 0;
					  pUPAlarmTime_LL_Press = 0;
				  }
			  }
		  }
	}
	else  //出液压力下限检测关闭
	{
		gAlaFlag_LL_OutPress = 0;
		pUPAlarmTime_LL_Press = 0;
	}
}

/**
* @函数名	FML_Alarm_Maint
* @功能	    设备维护报警
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Maint(void)
{
	if(UP.Para.AlarmType_Maint != 2)
	{
		  //水泵
		  if(gRunTime_Pump > 20000)  //20000小时
		  {
			  gAlaFlag_PumpMaint = 1;
		  }
		  else
		  {
			  gAlaFlag_PumpMaint = 0;
		  }

		  //压机1
		  if(gRunTime_Comp > 30000)  //30000小时
		  {
			  gAlaFlag_CompMaint = 1;
		  }
		  else
		  {
			  gAlaFlag_CompMaint = 0;
		  }

		  //压机2
		  if(FP.Para.Type_CompNumber == 1)  //双机头
		  {
			  if(gRunTime_Comp2 > 30000)  //30000小时
			  {
				  gAlaFlag_Comp2Maint = 1;
			  }
			  else
			  {
				  gAlaFlag_Comp2Maint = 0;
			  }
		  }
		  else
		  {
			  gAlaFlag_Comp2Maint = 0;
		  }

		  //过滤器
		  if(gRunTime_Filter > UP.Para.CycleTime_Filter)  //单位小时
		  {
			  gAlaFlag_FilterMaint = 1;
		  }
		  else
		  {
			  gAlaFlag_FilterMaint = 0;
		  }
	}
	else
	{
		gAlaFlag_PumpMaint = 0;
		gAlaFlag_CompMaint = 0;
		gAlaFlag_Comp2Maint = 0;
		gAlaFlag_FilterMaint = 0;
	}
}

/**
* @函数名	FML_Alarm_OverFlow
* @功能	    用户溢流开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_OverFlow(void)
{
	static uint16_t pUPAlarmTime_OverFlow = 0;		//溢流开关报警延时

	if(UP.Para.AlarmType_OverFlow != 2)  //报警
	{
		switch(DRI_EQU_GetFunState(OVER_LEVEL))  //工厂输入1配置为泄漏报警
		{
		case ON:
			 if(++pUPAlarmTime_OverFlow > 40)  //溢流延时
			  {
				  gAlaFlag_OverFlow = 1;
				  pUPAlarmTime_OverFlow = 40;
			  }
			break;
		case OFF:
			pUPAlarmTime_OverFlow = 0;
			gAlaFlag_OverFlow = 0;
			break;
		default:
			gAlaFlag_OverFlow = 0;
			pUPAlarmTime_OverFlow = 0;
			break;
		}
	}
	else  //关闭
	{
		gAlaFlag_OverFlow = 0;
		pUPAlarmTime_OverFlow = 0;
	}
}

/**
* @函数名	FML_Alarm_Press
* @功能	    高低压报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Press(void)
{
	static uint16_t pUPAlarmTime_ReHighPress = 0;		//高压报警延时
	static uint16_t pUPAlarmTime_ReLowPress = 0;		//低压报警延时
	static uint16_t pUPAlarmTime_RePress1 = 0;		//回路1报警延时
	static uint16_t pUPAlarmTime_RePress2 = 0;		//回路2报警延时

    if(gLastState_Comp == 1)  //压缩机开机
    {
    	if(gTime_RunComp <= 200)  //压缩机开机计时
    	{
    		gTime_RunComp++;
    	}
    }
    else  //压缩机关机
    {
    	gTime_RunComp = 0;
    }

	if((gTime_RunComp > 200))  //压缩机启动时间大于20秒
	{
	    switch(DRI_EQU_GetFunState(RE_HIGHT_PRESS))
	    {
	    case ON:
	    	 if(++pUPAlarmTime_ReHighPress > 40)  //高压延时
			  {
				  gAlaFlag_RefHighPress = 1;
				  pUPAlarmTime_ReHighPress = 40;
			  }
	    	break;
	    case OFF:
	    	gAlaFlag_RefHighPress = 0;
	    	pUPAlarmTime_ReHighPress = 0;
	    	break;
	    default:
	    	gAlaFlag_RefHighPress = 0;
	    	pUPAlarmTime_ReHighPress = 0;
	    	break;
	    }

	    switch(DRI_EQU_GetFunState(RE_PRESS1))//回路1氟压报警
		{
		case ON:
			 if(++pUPAlarmTime_RePress1 > 40)  //回路1延时
			  {
				  gAlaFlag_RefPress1 = 1;
				  pUPAlarmTime_RePress1 = 40;
			  }
			break;
		case OFF:
			gAlaFlag_RefPress1 = 0;
			pUPAlarmTime_RePress1 = 0;
			break;
		default:
			gAlaFlag_RefHighPress = 0;
			pUPAlarmTime_ReHighPress = 0;
			gAlaFlag_RefPress1 = 0;
			pUPAlarmTime_RePress1 = 0;
			break;
		}

	    switch(DRI_EQU_GetFunState(RE_LOW_PRESS))//低压报警
		{
		case ON:
			 if(++pUPAlarmTime_ReLowPress > 40)  //低压延时
			  {
				  gAlaFlag_RefLowPress = 1;
				  pUPAlarmTime_ReLowPress = 40;
			  }
			break;
		case OFF:
			gAlaFlag_RefLowPress = 0;
			pUPAlarmTime_ReLowPress = 0;
			break;
		default:
			gAlaFlag_RefLowPress = 0;
			pUPAlarmTime_ReLowPress = 0;
			break;
		}

	    switch(DRI_EQU_GetFunState(RE_PRESS2))//回路2报警
		{
		case ON:
			if(++pUPAlarmTime_RePress2 > 40)  //回路2延时
			{
				gAlaFlag_RefPress2 = 1;
				pUPAlarmTime_RePress2 = 40;
			}
			break;
		case OFF:
			 gAlaFlag_RefPress2 = 0;
			pUPAlarmTime_RePress2 = 0;
			break;
		default:
			gAlaFlag_RefLowPress = 0;
			pUPAlarmTime_ReLowPress = 0;
			gAlaFlag_RefPress2 = 0;
			pUPAlarmTime_RePress2 = 0;
			break;
		}
	}
}

/**
* @函数名	FML_Alarm_DI
* @功能	    水质报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_DI(void)
{
	if(UP.Para.AlarmType_DISensor != 0)  //水质检测未关闭
	{
		if(gPV_DI < UP.Para.Alarm_LL_DI)  //水质超过下限
		{
			gAlaFlag_LL_DI = 1;
		}
		else
		{
			gAlaFlag_LL_DI = 0;
		}
	}
	else  //关闭
	{
		gAlaFlag_LL_DI = 0;
	}
}

/**
* @函数名	FML_Alarm_TempSensor1
* @功能	    主温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor1(void)
{
	if((gPV_Temp1 < -50) || (gPV_Temp1 > 150))  //温度异常
	{
		  gAlaFlag_TempSensor1 = 1;
	}
	else
	{
		  gAlaFlag_TempSensor1 = 0;
	}
}

/**
* @函数名	FML_Alarm_TempSensor2
* @功能	    辅温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor2(void)
{
	if(FP.Para.ES_Temp2 == 1)
	{
		if((gPV_Temp2 < -50) || (gPV_Temp2 > 150))  //温度异常
		{
			  gAlaFlag_TempSensor2 = 1;
		}
		else
		{
			  gAlaFlag_TempSensor2 = 0;
		}
	}
	else
	{
		gAlaFlag_TempSensor2 = 0;
	}
}

/**
* @函数名	FML_Alarm_TempSensor3
* @功能	    环境温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor3(void)
{
	if(FP.Para.ES_TempAmbi == 1)
	{
		if((gPV_TempAbmi < -50) || (gPV_TempAbmi > 150))  //温度异常
		{
			  gAlaFlag_TempSensor3 = 1;
		}
		else
		{
			  gAlaFlag_TempSensor3 = 0;
		}
	}
	else
	{
		gAlaFlag_TempSensor3 = 0;
	}
}

/**
* @函数名	FML_Alarm_TempSensor_Tc
* @功能	    冷凝温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor_Tc(void)
{
	if(FP.Para.ES_Tc != 0)
	{
		if((gSlaver_Temp2 < -99) || (gSlaver_Temp2 > 99))  //温度异常
		{
			gAlaFlag_TempSensor_Tc1 = 1;
		}
	}
	else
	{
		gAlaFlag_TempSensor_Tc1 = 0;
	}
}
/**
* @函数名	FML_Alarm_TempSensor_Te
* @功能	    蒸发温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor_Te(void)
{
	static uint16_t pAlarmTime_gSlaver_Temp = 0;		//蒸发温度异常报警计时

	if(FP.Para.ES_Te != 0)
	{
		if((gSlaver_Temp1 < -99) || (gSlaver_Temp1 > 99))  //温度异常
		{
			  gAlaFlag_TempSensor_Te1 = 1;
		}
		else
		{
			if(gTime_RunComp > 200)
			{
				if(gSlaver_Temp1 < FP.Para.LL_TempPV_Te1 && (++pAlarmTime_gSlaver_Temp > 200))
				{
					gAlaFlag_LL_Te1 = 1;  //蒸发温度下限限值报警标志
				}
			}
			else
			{
				pAlarmTime_gSlaver_Temp = 0;
				//gAlaFlag_LL_Te1 = 0;  //蒸发温度下限限值报警标志
			}

			if(gTime_RunComp > 200)
			{
				if(gSlaver_Temp1 > FP.Para.HL_TempPV_Te1 && (++pAlarmTime_gSlaver_Temp > 200))
				{
					gAlaFlag_HL_Te1 = 1;  //蒸发温度上限限值报警标志
				}
			}
			else
			{
				pAlarmTime_gSlaver_Temp = 0;
				//gAlaFlag_HL_Te1 = 0;  //蒸发温度上限限值报警标志
			}
		}
	}
	else
	{
		gAlaFlag_TempSensor_Te1 = 0;
	}
}

/**
* @函数名	FML_Alarm_TempSensor_To
* @功能	    出气温度传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_TempSensor_To(void)
{
	static uint16_t pAlarmTime_gSlaver_Temp3 = 0;
	if(FP.Para.ES_To != 0)
	{
		if((gSlaver_Temp3 < -99) || (gSlaver_Temp3 > 999))  //温度异常
		{
			gAlaFlag_TempSensor_To1 = 1;
		}
		else
		{
			if(gSlaver_Temp3 > FP.Para.HL_TempPV_To1)
			{
				if (++pAlarmTime_gSlaver_Temp3 > 200)
				{
					gAlaFlag_HL_To1 = 1;  //出气温度上限限值报警标志
				}
			}
			else
			{
				pAlarmTime_gSlaver_Temp3 = 0;
			}
		}
	}
	else
	{
		pAlarmTime_gSlaver_Temp3 = 0;
		gAlaFlag_TempSensor_To1 = 0;
	}
}

/**
* @函数名	FML_Alarm_PressSensor_Te
* @功能	    蒸发压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressSensor_Te(void)
{
	if(gTime_RunComp > 200)  //压缩机启动时间大于20秒
	{
		if((gSlaver_Press_Temp1 < -99) || (gSlaver_Press_Temp1 > 99))  //温度异常
		{
			  gAlaFlag_PressSensor_Te1 = 1;
		}
	}
}

/**
* @函数名	FML_Alarm_PressSensor_Tc
* @功能	    冷凝压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressSensor_Tc(void)
{
	if(FP.Para.ES_Pc == 1)
	{
		if(gTime_RunComp > 200)  //压缩机启动时间大于20秒
		{
			if((gSlaver_Press_Temp2 < -99) || (gSlaver_Press_Temp2 > 99))  //温度异常
			{
				gAlaFlag_PressSensor_Tc1 = 1;
			}
		}
	}
	else
	{
		gAlaFlag_PressSensor_Tc1 = 0;
	}
}

/**
* @函数名	FML_Alarm_FlowSensor
* @功能	    流量传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_FlowSensor(void)
{
	if(UP.Para.AlarmType_FlowSensor != 2)  //流量传感器使能
	{
		if(gPV_Flow < 0)  //流量异常
		{
			  gAlaFlag_FlowSensor = 1;  //报警
		}
		else
		{
			  gAlaFlag_FlowSensor = 0;  //无报警
		}
	}
	else
	{
		gAlaFlag_FlowSensor = 0;  //无报警
	}
}

/**
* @函数名	FML_Alarm_PressOutSensor
* @功能	    出液压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressOutSensor(void)
{
	if(UP.Para.AlarmType_OutPressSensor != 2)  //出液压力传感器使能
	{
		if(gPV_Press_Out < 0)  //出液压力异常
		{
			gAlaFlag_PressOutSensor = 1;  //报警
		}
		else  //出液压力正常
		{
			if(UP.Para.AlarmType_OutPressSensor == 0)  //报警模式
			{
				gAlaFlag_PressOutSensor = 0;  //无报警
			}
		}
	}
	else
	{
		gAlaFlag_PressOutSensor = 0;  //报警
	}
}

/**
* @函数名	FML_Alarm_PressSensor1
* @功能	    高压传感器  氟路1压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressSensor1(void)
{
	static uint16_t pAlarmTime_ReHighPress = 0;		//报警延时
	static uint16_t pAlarmTime_RePress1 = 0;		//报警延时
	static uint16_t pAlarmTime_ReLowPress = 0;		//报警延时
	static uint16_t pAlarmTime_RePress2 = 0;		//报警延时

		if(gLastState_Comp == 0)  //压缩机关机
		{
			if(DRI_EQU_GetFunState(RE_HIGHT_PRESS) == ON)  //氟路高压压力传感器报警
			{
				if(++pAlarmTime_ReHighPress > 20)
				{
					gAlaFlag_RefHighPressSensor = 1;
					pAlarmTime_ReHighPress = 20;
				}
			}
			else
			{
				gAlaFlag_RefHighPressSensor = 0;
			}

			if(DRI_EQU_GetFunState(RE_LOW_PRESS) == ON)  //氟路低压压力传感器报警
			{
				if(++pAlarmTime_ReLowPress > 20)
				{
					gAlaFlag_RefLowPressSensor = 1;
					pAlarmTime_ReLowPress = 20;
				}
			}
			else
			{
				gAlaFlag_RefLowPressSensor = 0;
			}

			if(DRI_EQU_GetFunState(RE_PRESS1) == ON)  //回路1压力传感器报警
			{
				if(++pAlarmTime_RePress1 > 20)
				{
					gAlaFlag_RefPressSensor1 = 1;
					pAlarmTime_RePress1 = 20;
				}
			}
			else
			{
				gAlaFlag_RefPressSensor1 = 0;
			}

			if(DRI_EQU_GetFunState(RE_PRESS2) == ON)  //回路2压力传感器报警
			{
				if(++pAlarmTime_RePress2 > 20)
				{
					gAlaFlag_RefPressSensor2 = 1;
					pAlarmTime_RePress2 = 20;
				}
			}
			else
			{
				gAlaFlag_RefPressSensor2 = 0;
			}
		}
}

/**
* @函数名	FML_Alarm_PressSensor2
* @功能	    低压传感器  氟路2压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressSensor2(void)
{

}

/**
* @函数名	FML_Alarm_PressInSensor
* @功能	    回液压力传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_PressInSensor(void)
{
	if(UP.Para.AlarmType_InPressSensor != 2)  //回液压力传感器使能
	{
		if(gPV_Press_In < 0)  //回液压力异常
		{
			gAlaFlag_PressInSensor = 1;  //报警
		}
		else
		{
			gAlaFlag_PressInSensor = 0;  //无报警
		}
	}
	else
	{
		gAlaFlag_PressInSensor = 0;  //报警
	}
}

/**
* @函数名	FML_Alarm_DISensor
* @功能	    水质传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_DISensor(void)
{
	if(UP.Para.AlarmType_DISensor != 2)  //水质检测使能
	{
		if(gPV_DI < 0)  //水质检测异常
		{
			gAlaFlag_DISensor = 1;  //报警
		}
		else
		{
			gAlaFlag_DISensor = 0;  //无报警
		}
	}
	else
	{
		gAlaFlag_DISensor = 0;  //报警
	}
}

/**
* @函数名	FML_Alarm_CHWFlowSensor
* @功能	    出液低流量开关传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_CHWFlowSensor(void)
{
	static uint16_t pAlarmTime_CHWFlowSensor = 0;		//低流量开关异常报警计时

	if(FP.Para.ES_InFlowLL  == 2)  //出液低流量开关使能
	{
		if(gLastState_Pump == 0)  //水泵关机
		{
			if(DRI_EQU_GetFunState(OUTPUT_LOW_FLOW) == OFF)  //有流量
			{
				if(++pAlarmTime_CHWFlowSensor > 40)  //4S
				{
					gAlaFlag_OutFlowSensor = 1;  //传感器异常
					pAlarmTime_CHWFlowSensor = 40;
				}
			}
			else
			{
				gAlaFlag_OutFlowSensor = 0;  //传感器正常
				pAlarmTime_CHWFlowSensor = 0;
			}
		}
	}
	else
	{
		gAlaFlag_OutFlowSensor = 0;  //传感器正常
		pAlarmTime_CHWFlowSensor = 0;
	}
}

/**
* @函数名	FML_Alarm_InFlowSensor
* @功能	    内循环低流量开关传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_InFlowSensor(void)
{
	static uint16_t pAlarmTime_InFlowSensor = 0;		//内循环低流量开关异常报警计时

	if(FP.Para.ES_InFlowLL  == 1)  //内循环低流量开关使能
	{
		if(gLastState_Pump == 0)  //水泵关机
		{
			if(DRI_EQU_GetFunState(OUTPUT_LOW_FLOW) == OFF)  //有流量
			{
				if(++pAlarmTime_InFlowSensor > 40)  //4S
				{
					gAlaFlag_InFlowSensor = 1;  //传感器异常
					pAlarmTime_InFlowSensor = 40;
				}
			}
			else
			{
				gAlaFlag_InFlowSensor = 0;  //传感器正常
				pAlarmTime_InFlowSensor = 0;
			}
		}
	}
	else
	{
		gAlaFlag_InFlowSensor = 0;  //传感器正常
		pAlarmTime_InFlowSensor = 0;
	}
}

/**
* @函数名	FML_Alarm_LevelSensor
* @功能	    液位开关传感器检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_LevelSensor(void)
{
	static uint16_t pAlarmTime_LevelSensor = 0;		//低液位开关异常报警计时

	if(DRI_EQU_GetFunState(LOW_LEVEL_ALARM) != STATE_NO_CONFIG)  //低液位上报警已配置
	{
		if(DRI_EQU_GetFunState(HIGHT_LEVEL) == STATE_NO_CONFIG)  //无高液位报警
		{
			if(gAlaFlag_LowLevelUP == 0)  //无低液位报警
			{
				if(gAlaFlag_LowLevel == 1)  //低液位故障
				{
					if(++pAlarmTime_LevelSensor > 20)  //2S
					{
						gAlmFlag_LevelSensor = 1;  //液位开关故障
						pAlarmTime_LevelSensor = 20;
					}
				}
				else
				{
					gAlmFlag_LevelSensor = 0;
					pAlarmTime_LevelSensor = 0;
				}
			}
			else
			{
				gAlmFlag_LevelSensor = 0;
				pAlarmTime_LevelSensor = 0;
			}
		}
		else  //有高液位报警
		{
			if(gAlaFlag_HighLevel == 0)  //无高液位报警
			{
				if(gAlaFlag_LowLevelUP == 0)  //无低液位报警
				{
					if(gAlaFlag_LowLevel == 1)  //低液位故障
					{
						if(++pAlarmTime_LevelSensor > 20)  //2S
						{
							gAlmFlag_LevelSensor = 1;  //液位开关故障
							pAlarmTime_LevelSensor = 20;
						}
					}
					else
					{
						gAlmFlag_LevelSensor = 0;
						pAlarmTime_LevelSensor = 0;
					}
				}
			}
			else  //有高液位报警
			{
				if((gAlaFlag_LowLevelUP == 1) || (gAlaFlag_LowLevel == 1))  //有低液位
				{
					if(++pAlarmTime_LevelSensor > 20)  //2S
					{
						gAlmFlag_LevelSensor = 1;  //液位开关故障
						pAlarmTime_LevelSensor = 20;
					}
				}
				else
				{
					gAlmFlag_LevelSensor = 0;
					pAlarmTime_LevelSensor = 0;
				}
			}
		}
	}
	else
	{
		gAlmFlag_LevelSensor = 0;
		pAlarmTime_LevelSensor = 0;
	}
}

/**
* @函数名	FML_Alarm_Communication
* @功能	    通讯检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Communication(void)
{
	if((UP.Para.RS485_State != 0))  //通讯异常
	{
		  gAlaFlag_Communication = 1;
	}
	else
	{
		  gAlaFlag_Communication = 0;
	}
}

/**
* @函数名	FML_Alarm_SlaverLowPress
* @功能	    从机氟压限值报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_SlaverLowPress(void)
{
	static uint16_t pSlaverAlarmTime_Press1 = 0;		//从机压力1低压限值报警延时
	static uint16_t pSlaverAlarmTime_Press2 = 0;		//从机压力2低压限值报警延时

	if(FP.Para.SV_AlarmTime_Press1 != 9990)  //999S
	{
		if(gSlaver_Press1 < FP.Para.SV_Alarm_Press1)  //氟压低
		{
			if(++pSlaverAlarmTime_Press1 > FP.Para.SV_AlarmTime_Press1)
			{
				gSlaver_AlaFlag_Press1 = 1;
				pSlaverAlarmTime_Press1 = FP.Para.SV_AlarmTime_Press1;
			}
		}
		else  //压力正常
		{
			pSlaverAlarmTime_Press1 = 0;
		}
	}
	else
	{
		pSlaverAlarmTime_Press1 = 0;
		gSlaver_AlaFlag_Press1 = 0;
	}

	if(FP.Para.ES_Pc == 1)  //使能
	{
		if(FP.Para.SV_AlarmTime_Press2 != 9990)  //999S
		{
			if(gSlaver_Press2 > FP.Para.SV_Alarm_Press2)  //氟压高
			{
				if(++pSlaverAlarmTime_Press2 > FP.Para.SV_AlarmTime_Press2)
				{
					gSlaver_AlaFlag_Press2 = 1;
					pSlaverAlarmTime_Press2 = FP.Para.SV_AlarmTime_Press2;
				}
			}
			else  //压力正常
			{
				pSlaverAlarmTime_Press2 = 0;
			}
		}
		else
		{
			pSlaverAlarmTime_Press2 = 0;
			gSlaver_AlaFlag_Press2 = 0;
		}
	}
	else
	{
		pSlaverAlarmTime_Press2 = 0;
		gSlaver_AlaFlag_Press2 = 0;
	}
}

/**
* @函数名	FML_Alarm_SlaverLowPress
* @功能	    从机氟压高压开关报警检测
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_SlaverHighPress(void)
{
	static uint16_t pSlaverAlarmTime_PressSW2 = 0;		//从机压力2高压开关报警延时

	if(FP.Para.EW_Pc == 1)  //氟压高压开关检测使能
	{
		if(gSlaver_DigitalIn2 == 1)  //高压开关报警
		{
			if(++pSlaverAlarmTime_PressSW2 > 40)  //延时4S
			{
				gSlaver_AlaFlag_PressSW2 = 1;
				pSlaverAlarmTime_PressSW2 = 40;
			}
		}
	}
	else
	{
		gSlaver_AlaFlag_PressSW2 = 0;
		pSlaverAlarmTime_PressSW2 = 0;
	}
}

/**
* @函数名	FML_Alarm_Tran
* @功能	    报警汇总
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Tran(void)
{
	if((gAlaFlag_FacHighTemp == 0) && (gAlaFlag_FacLowTemp == 0) && (gAlaFlag_RefHighPress == 0) && (gAlaFlag_RefLowPress == 0) && (gAlaFlag_COWLowFlow == 0) && (gAlaFlag_TempSensor_Tc1 == 0) && (gAlaFlag_TempSensor_Te1 == 0) && (gAlaFlag_TempSensor_To1 == 0) && (gAlaFlag_PressSensor_Te1 == 0) && (gAlaFlag_HL_Te1 == 0) && (gAlaFlag_LL_Te1 == 0) && (gAlaFlag_HL_To1 == 0))
	{
		  gAlaFlag_CompFLT = 0;
	}
	if((gAlaFlag_LowLevel == 0) && (gAlaFlag_HighTemp == 0) && (gAlaFlag_LowTemp == 0) && (gAlaFlag_FlowSensor == 0) && (gAlaFlag_EStop == 0) && (gAlaFlag_ESwitch1 == 0) && (gAlaFlag_ESwitch2 == 0) && (gAlaFlag_OverFlow == 0) && (gAlaFlag_FacHighTemp == 0) && (gAlaFlag_FacLowTemp == 0) && (gAlaFlag_RefPressSensor1 == 0) && (gAlaFlag_RefPressSensor2 == 0) && (gAlaFlag_LowFlow == 0) && (gAlaFlag_InFlowSensor == 0) && (gAlaFlag_EEVCom == 0) && (gAlaFlag_RefNormalLowPress == 0))
	{
        gAlaFlag_FLT = 0;
	}
	if((gAlaFlag_LowLevel == 0) && (gAlaFlag_FacHighTemp == 0) && (gAlaFlag_HighTemp == 0))
	{
		gAlaFlag_HeaterFLT = 0;
	}

	if(gAlaFlag_LowLevel == 1)  //低液位
	{
		if(FP.Para.Type_LL_Level == 0)  //报警
		{
			gAlaFlag_HeaterFLT = 1;
		}
		else if(FP.Para.Type_LL_Level == 1)  //故障
		{
			gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
			gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_FacHighTemp == 1)  //高温
	{
		if(FP.Para.Type_HL_TempFF == 0)  //报警
		{
		  gAlaFlag_CompFLT = 1;
		  gAlaFlag_HeaterFLT = 1;
		}
		else if(FP.Para.Type_HL_TempFF == 1)  //故障
		{
			gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_FacLowTemp == 1)  //低温
	{
		if(FP.Para.Type_LL_TempFF == 0)  //报警
		{
			gAlaFlag_CompFLT = 1;
		}
		else if(FP.Para.Type_LL_TempFF == 1)  //故障
		{
			gAlaFlag_FLT = 1;
		}
	}
	if((gAlaFlag_RefHighPress == 1) || (gAlaFlag_RefLowPress == 1))  //氟路高低压
	{
		  gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_RefNormalLowPress == 1)
	{
		 gAlaFlag_FLT = 1;
	}
	if((gAlaFlag_TempSensor_Tc1 == 1) || (gAlaFlag_TempSensor_Te1 == 1) || (gAlaFlag_TempSensor_To1 == 1))  //氟路温度传感器
	{
		  gAlaFlag_CompFLT = 1;
	}
	if((gAlaFlag_HL_Te1 == 1) || (gAlaFlag_LL_Te1 == 1))//蒸发温度超上下限制
	{
		gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_HL_To1 == 1)//出气温度超上限制
	{
		gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_PressSensor_Te1 == 1)//蒸发压力传感器异常
	{
		gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_PressSensor_Tc1 == 1)//冷凝压力传感器异常
	{
		gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_COWLowFlow == 1)  //冷却水低流量
	{
		  gAlaFlag_CompFLT = 1;
	}
	if(gAlaFlag_OverFlow == 1)  //溢流
	{
		if(UP.Para.AlarmType_OverFlow == 1)  //故障
		{
			gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
			gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_RefHighPressSensor == 1)  //高压氟压传感器故障
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_RefLowPressSensor == 1)  //低压氟压传感器故障
	{
		gAlaFlag_FLT = 1;
	}
	if(rFlag_Comp != 0)  //变频器1存在故障
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_PumpCom1 == 1)  //变频器1通讯异常
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_HighTemp == 1)  //高温
	{
		  if(UP.Para.AlarmType_TempHL == 0)  //报警
		  {
			  gAlaFlag_HeaterFLT = 1;
		  }
		  else if(UP.Para.AlarmType_TempHL == 1)  //故障
		  {
			  gAlaFlag_FLT = 1;
		  }
	}
	if(gAlaFlag_LowTemp == 1)  //低温
	{
		  if(UP.Para.AlarmType_TempLL == 1)  //故障
		  {
			  gAlaFlag_FLT = 1;
		  }
	}

	if(gAlaFlag_TempSensor1 == 1)  //主温度传感器
	{
		  gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_LowFlow == 1)  //用户低流量限值
	{
		  if(UP.Para.AlarmType_FlowLL == 1)  //故障
		  {
			  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
			  gAlaFlag_FLT = 1;
			  gFltState_LowFlow = 0;  //低流量报警状态
			  gAlaState_LowFlow = 1;  //低流量故障状态
		  }
		  else
		  {
			  gAlaState_LowFlow = 0;  //低流量故障状态
			  gFltState_LowFlow = 1;  //低流量报警状态
		  }
	}
	else  //低流量无异常
	{
		  gFltState_LowFlow = 0;  //低流量报警状态
		  gAlaState_LowFlow = 0;  //低流量故障状态
	}
	if(gAlaFlag_FacLowFlow == 1)  //工厂出液低流量
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_FacInLowFlow == 1)  //工厂内循环低流量
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_FacLowFlow1 == 1)  //工厂保护低流量限值
	{
		if(FP.Para.Type_LL_Flow == 1)  //故障
		{
			gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_FlowSensor == 1)    //流量传感器
	{
		if(UP.Para.AlarmType_FlowSensor == 1)  //故障
		{
		  gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_InFlowSensor == 1)  //内循环低流量开关异常
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_HL_OutPress == 1)  //出液高压力
	{
		if(UP.Para.AlarmType_PressHL == 1)  //故障
		{
		  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
		  gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_LL_OutPress == 1)  //出液低压力
	{
		if(UP.Para.AlarmType_PressLL == 1)  //故障
		{
		  gTime_StopPump = UP.Para.Time_StopDelayPump*5 + 1;  //取消本次延时停泵直接停泵
		  gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_PressOutSensor == 1)  //出液压力传感器
	{
		if(UP.Para.AlarmType_OutPressSensor == 1)  //故障
		{
			gAlaFlag_FLT = 1;
		}
	}
	if(gAlaFlag_EStop == 1)  //急停按钮
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_ESwitch1 == 1)  //外部保护故障1
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_ESwitch2 == 1)  //外部保护故障2
	{
		gAlaFlag_FLT = 1;
	}
	if(gAlaFlag_EEVCom == 1)  //EEV通讯异常
	{
		gAlaFlag_FLT = 1;
	}


	if(gSlaver_AlaFlag_Press1 == 1)  //从机压力1故障
	{
		gAlaFlag_CompFLT = 1;
	}

	if(gSlaver_AlaFlag_Press2 == 1)  //从机压力2故障
	{
		gAlaFlag_CompFLT = 1;
	}

	if(gSlaver_AlaFlag_PressSW2 == 1)  //从机压力2开关高压故障
	{
		gAlaFlag_CompFLT = 1;
	}
}

/**
* @函数名	FML_Alarm_Update
* @功能	    报警状态更新
* @入口参数	无
* @返回值	无
*/
void FML_Alarm_Update(void)
{
	uint8_t i;
	uint8_t pAlaCnt = 0;

	//报警组状态更新
	rState_Alarm1 = (gAlaFlag_LowLevel & 0x01) |
			((gAlaFlag_LowLevelUP & 0x01)<<1) |
			((gAlmFlag_LevelSensor & 0x01)<<2) |
			((gSlaver_AlaFlag_Press1 & 0x01)<<3) |
			((gAlaFlag_HighLevel & 0x01)<<4) |
			((gAlaFlag_HighTemp & 0x01)<<6) |
			((gAlaFlag_LowTemp & 0x01)<<7) |
			((gAlaFlag_HighTemp1 & 0x01)<<8) |
			((gAlaFlag_LowTemp1 & 0x01)<<9) |
			((gAlaFlag_PressOutSensor & 0x01)<<14) |
			((gAlaFlag_HL_OutPress & 0x01)<<15);
	rState_Alarm2 = ((gAlaFlag_LL_OutPress & 0x01)<<1) |
			((gAlaFlag_PressInSensor & 0x01)<<3) |
			((gAlaFlag_FlowSensor & 0x01)<<8) |
			((gAlaFlag_LowFlow & 0x01)<<9) |
			((gAlaFlag_FacLowFlow & 0x01)<<10) |
			((gAlaFlag_DISensor & 0x01)<<11) |
			((gAlaFlag_LL_DI & 0x01)<<12) |
			((gAlaFlag_TempSensor1 & 0x01)<<15);
	rState_Alarm3 = ((gAlaFlag_RefNormalLowPress & 0x01)<<0) |
			((gAlaFlag_Communication & 0x01)<<1) |
			((gAlaFlag_RefHighPress & 0x01)<<2) |
			((gAlaFlag_RefLowPress & 0x01)<<3) |
			((gAlaFlag_PumpCom1 & 0x01)<<6) |
			((gAlaFlag_CompMaint & 0x01)<<8) |
			((gAlaFlag_Comp2Maint & 0x01)<<9) |
			((gAlaFlag_InFlowSensor & 0x01)<<10) |
			((gAlaFlag_OutFlowSensor & 0x01)<<11) |
			((gAlaFlag_PumpMaint & 0x01)<<12) |
			((gSlaver_AlaFlag_Press2 & 0x01)<<13) |
			((gAlaFlag_FilterMaint & 0x01)<<14) |
			((gAlaFlag_FacInLowFlow & 0x01)<<15);
	rState_Alarm4 = (gAlaFlag_COWLowFlow & 0x01) |
			((gAlaFlag_TempSensor2 & 0x01)<<1) |
			((gAlaFlag_EStop & 0x01)<<2) |
			((gAlaFlag_ESwitch1 & 0x01)<<3) |
			((gAlaFlag_ESwitch2 & 0x01)<<4) |
			((gAlaFlag_OverFlow & 0x01)<<5) |
			((gAlaFlag_TempSensor3 & 0x01)<<6) |
			((gAlaFlag_FacHighTemp & 0x01)<<7) |
			((gAlaFlag_FacLowTemp & 0x01)<<8) |
			((gAlaFlag_RefHighPressSensor & 0x01)<<9) |
			((gAlaFlag_RefLowPressSensor & 0x01)<<10) |
			((gAlaFlag_RefPressSensor1 & 0x01)<<11) |
			((gAlaFlag_RefPress1 & 0x01)<<12) |
			((gAlaFlag_RefPressSensor2 & 0x01)<<13) |
			((gAlaFlag_RefPress2 & 0x01)<<14) |
			(gAlaFlag_FacLowFlow1 & 0x01)<<15;
	rState_Alarm5 = (gAlaFlag_TempSensor_Tc1 & 0x01) |
				((gAlaFlag_TempSensor_Te1 & 0x01)<<1) |
				((gAlaFlag_TempSensor_To1 & 0x01)<<2) |
				((gAlaFlag_PressSensor_Tc1 & 0x01)<<3) |
				((gAlaFlag_PressSensor_Te1 & 0x01)<<4) |
				((gAlaFlag_HL_Te1 & 0x01)<<10) |
				((gAlaFlag_LL_Te1 & 0x01)<<11) |
				((gAlaFlag_EEVCom & 0x01)<<12) |
				((gAlaFlag_HL_To1 & 0x01)<<14) |
				((gSlaver_AlaFlag_PressSW2 & 0x01)<<15);



	//所有报警状态更新
	if((rState_Alarm1 != 0) || (rState_Alarm2 != 0) || (rState_Alarm3 != 0) || (rState_Alarm4 != 0) || (rState_Alarm5 != 0)|| (rFlag_Comp != 0))
	{
		gBuzzerFlag_Ctl = 1;
	}
	else
	{
		gBuzzerFlag_Ctl = 0;
	}

	//报警数量更新
	for(i = 0; i < 16; i++)
	{
		if((rState_Alarm1 >> i) & 0x0001)
		{
			pAlaCnt++;
		}

		if((rState_Alarm2 >> i) & 0x0001)
		{
			pAlaCnt++;
		}

		if((rState_Alarm3 >> i) & 0x0001)
		{
			pAlaCnt++;
		}

		if((rState_Alarm4 >> i) & 0x0001)
		{
			pAlaCnt++;
		}

		if((rState_Alarm5 >> i) & 0x0001)
		{
			pAlaCnt++;
		}

		if((rFlag_Comp >> i) & 0x0001)
		{
			pAlaCnt++;
		}
	}

	gAlaFlag_Num = pAlaCnt;

}
